package com.minimalist.common.entity.basic.vo.tenant;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.minimalist.common.config.convert.LongArrJsonSerializer;
import com.minimalist.common.config.swagger.SchemaEnum;
import com.minimalist.common.entity.basic.enums.StatusEnum;
import com.minimalist.common.utils.Add;
import com.minimalist.common.utils.Update;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * @author 11987
 */
@Schema(name = "租户套餐实体")
public class TenantPackageVO implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    @JsonSerialize(using = ToStringSerializer.class)
    @NotNull(message = "租户套餐ID不能为空", groups = {Update.class})
    @Schema(name = "packageId", description = "租户套餐ID", type = "string")
    private Long packageId;

    @NotNull(message = "套餐名称能为空", groups = {Add.class, Update.class})
    @Schema(name = "packageName", description = "套餐名称", type = "string")
    private String packageName;

    @NotNull(message = "租户套餐状态不能为空", groups = {Update.class})
    @SchemaEnum(implementation = StatusEnum.class)
    @Schema(name = "status", description = "租户套餐状态", type = "integer")
    private Byte status;

    @Schema(name = "remark", description = "备注", type = "string")
    private String remark;

    @Schema(name = "checkedPermIds", description = "租户套餐权限编码集合，用于回显", type = "array")
    private List<String> checkedPermIds;

    @JsonSerialize(using = LongArrJsonSerializer.class)
    @NotEmpty(message = "租户套餐权限不能为空", groups = {Add.class, Update.class})
    @Schema(name = "permissionsIds", description = "租户套餐权限编码集合", type = "array")
    private List<Long> permissionsIds;

    public Long getPackageId() {
        return packageId;
    }

    public void setPackageId(Long packageId) {
        this.packageId = packageId;
    }

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public Byte getStatus() {
        return status;
    }

    public void setStatus(Byte status) {
        this.status = status;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public List<String> getCheckedPermIds() {
        return checkedPermIds;
    }

    public void setCheckedPermIds(List<String> checkedPermIds) {
        this.checkedPermIds = checkedPermIds;
    }

    public List<Long> getPermissionsIds() {
        return permissionsIds;
    }

    public void setPermissionsIds(List<Long> permissionsIds) {
        this.permissionsIds = permissionsIds;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TenantPackageVO that = (TenantPackageVO) o;
        return Objects.equals(packageId, that.packageId) &&
               Objects.equals(packageName, that.packageName) &&
               Objects.equals(status, that.status) &&
               Objects.equals(remark, that.remark) &&
               Objects.equals(checkedPermIds, that.checkedPermIds) &&
               Objects.equals(permissionsIds, that.permissionsIds);
    }

    @Override
    public int hashCode() {
        return Objects.hash(packageId, packageName, status, remark, checkedPermIds, permissionsIds);
    }

    @Override
    public String toString() {
        return "TenantPackageVO{" +
               "packageId=" + packageId +
               ", packageName='" + packageName + '\'' +
               ", status=" + status +
               ", remark='" + remark + '\'' +
               ", checkedPermIds=" + checkedPermIds +
               ", permissionsIds=" + permissionsIds +
               '}';
    }
}
